import Vue from 'vue'
import Vuex from "vuex"
Vue.use(Vuex)
const store = new Vuex.Store({
	state:{
		hasLogin:false, // 是否已登录
		userInfo:{}
	},
	mutations:{
		login(state,user){
			// console.log('user是什么',user)
			state.hasLogin = true
			state.userInfo = user
			state.userInfo.token = user.token
			state.userInfo.username = user.username
			uni.setStorage({
				key:'userInfo',
				data:user
			})
			
		},
		logout(state){
			
			state.hasLogin = false
			state.userInfo = {}
			uni.removeStorage({
				key:'userInfo'
			})
		}
	}
})
export default store